﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MainSite.Master" AutoEventWireup="true" CodeBehind="TestListboxTransfer.aspx.cs" Inherits="BSCMFF.Web.Pages.working.TestListboxTransfer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<script type="text/javascript">
            //<![CDATA[
    var listBox;

    function pageLoad() {
        listBox = $find("<%= RadListBox1.ClientID %>");
    }

    function addItem() {
        var itemText = $find("<%= RadTextBox1.ClientID %>").get_value();
        if (!itemText) {
            alert("Please specify the text for the new item.");
            return false;
        }

        listBox.trackChanges();
        //Instantiate a new client item
        var item = new Telerik.Web.UI.RadListBoxItem();
        item.set_text(itemText);
        item.set_selected(true);

        listBox.get_items().add(item);
        item.scrollIntoView();
        listBox.commitChanges();
        return false;
    }

    function deleteItem() {
        if (listBox.get_items().get_count() < 1) {
            alert("The listBox is empty.");
            return false;
        }

        var selectedItem = listBox.get_selectedItem();
        if (!selectedItem) {
            alert("You need to select a item first.");
            return false;
        }

        if (listBox.get_items().get_count().length == 1) {
            if (!confirm("This is the last item in the listBox. Are you sure you want to delete it?"))
                return false;
        }

        listBox.deleteItem(selectedItem);
        return false;
    }

    function disableItem() {
        var selectedItem = listBox.get_selectedItem();
        if (!selectedItem) {
            alert("You need to select a item first.");
            return false;
        }

        listBox.trackChanges();

        selectedItem.disable();

        listBox.commitChanges();

        return false;
    }

    function enableAllItems() {
        for (var i = 0; i < listBox.get_items().get_count(); i++) {
            listBox.get_items().getItem(i).enable();
        }

        return false;
    }

    function reorderUp() {
        if (listBox.get_items().get_count() < 1) {
            alert("The listBox is empty.");
            return false;
        }

        var selectedItem = listBox.get_selectedItem();
        if (selectedItem == null) {
            alert("You need to select a item first.");
            return false;
        }

        var index = selectedItem.get_index();
        if (index < 1) {
            alert("Cannot reorder the first item");
            return false;
        }

        listBox.reorderItem(selectedItem, index - 1);
        return false;
    }

    function reorderDown() {
        if (listBox.get_items().get_count() < 1) {
            alert("The listBox is empty.");
            return false;
        }

        var selectedItem = listBox.get_selectedItem();
        if (selectedItem == null) {
            alert("You need to select a item first.");
            return false;
        }

        var index = selectedItem.get_index();
        if (index == listBox.get_items().get_count() - 1) {
            alert("Cannot reorder the last item");
            return false;
        }

        listBox.reorderItem(selectedItem, index + 1);
        return false;
    }

    function transferRight() {
        var listBox2 = $find("<%= RadListBox2.ClientID %>");

        var selectedItem = listBox2.get_selectedItem();
        if (selectedItem == null) {
            alert("You need to select a item first.");
            return false;
        }

        listBox2.transferToDestination(selectedItem);
        return false;
    }

    function transferLeft() {
        var listBox2 = $find("<%= RadListBox2.ClientID %>");
        var listBox3 = listBox2.get_transferTo();
        var selectedItem = listBox3.get_selectedItem();
        if (selectedItem == null) {
            alert("You need to select a item first.");
            return false;
        }

        listBox2.transferFromDestination(selectedItem);
        return false;
    }
            
            //]]>
        </script>

 
    
    <div class="topContainer">
       
         <div class="title">Available actions:</div>
            
         <ul class="qsfexAvailableActions">
             <li>
                 <asp:Button ID="Button5" CssClass="qsfButtonBig" OnClientClick="return reorderUp()" Text="Move Up" runat="server" />
                 <asp:Button ID="Button6" CssClass="qsfButtonBig" OnClientClick="return reorderDown()" Text="Move Down" runat="server" />
             </li>
             <li>
                 <asp:Button ID="Button4" CssClass="qsfButtonBig" OnClientClick="return disableItem()" Text="Disable Selected Item" runat="server" />
                 <asp:Button ID="Button7" CssClass="qsfButtonBig" OnClientClick="return enableAllItems()" Text="Enable All Items" runat="server" />
             </li>
             <li>
                 <asp:Button ID="Button3" CssClass="qsfButtonBig" OnClientClick="return deleteItem()" Text="Delete Selected Item" runat="server" />
             </li>
             <li>
                 <telerik:RadTextBox runat="server" ID="RadTextBox1" Text="New Item" />
                 <asp:Button ID="Button1" CssClass="qsfButton" OnClientClick="return addItem()" Text="Add New Item" runat="server" />
             </li>
             <li>
                 <asp:Button ID="Button2" CssClass="qsfButton" Text="Postback" runat="server" OnClick="Button2_Click" />
             </li>
         </ul>
        <telerik:RadListBox ID="RadListBox1" runat="server" Height="230px" /><br /><br />
    </div>

    <div style="overflow: hidden">
        
             <div class="title">Available actions:</div>
                
             <ul class="qsfexAvailableActions" style="clear: both">
                 <li>
                     <asp:Button ID="Button13" CssClass="qsfButtonBig" OnClientClick="return transferRight()" Text="Transfer Right" runat="server" />
                     <asp:Button ID="Button12" CssClass="qsfButtonBig" OnClientClick="return transferLeft()" Text="Transfer Left" runat="server" />
                 </li>
             </ul>

                    
     <telerik:RadListBox ID="RadListBox2" runat="server" Height="230px" TransferToID="RadListBox3" />
     <telerik:RadListBox ID="RadListBox3" runat="server" Height="230px" /><br />
    </div>


    <bsc:EmployeeGroupSelection ID="ds" runat="server" />
</asp:Content>
